package com.ccs.transmittal;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;

public class WebApp_Transmittal {

	static
	Admin_Transmittal_List atl = new Admin_Transmittal_List();
	
	//VERIFY LOCATION OF TRANSMITTAL ON WEBAPP IF CORRECT WITH ADMINAPP
	public void verify_transmittal_location(WebDriver driver, String loc){
		
		String web_loc = driver.findElement(By.xpath("//div[@id='mainContent']/div[7]/div/div/span[5]")).getText();
		String new_loc="";
                int intloc = 0;
                if (loc.equals("QC")){
                    intloc = 1;
                }
                if (loc.equals("GC")){
                    intloc = 2;
                }
		switch (intloc) {
			case 1:  new_loc = "QUEZON CITY";
					    break;
			case 2:  new_loc = "GLOBAL CITY";
					    break;
		}
		if(web_loc.equals(new_loc)){
			System.out.println(new_loc+" is CORRECT");
		}else{
			System.out.println(new_loc+" is INCORRECT");
		}
	}
	//VERIFY TRANSMITTAL NUMBER ON WEBAPP IF CORRECT WITH ADMINAPP
	public void verify_transmittal_number(WebDriver driver, String transmittalNo){
		
		String web_trans_no = driver.findElement(By.xpath("//div[@id='mainContent']/div[7]/div/div/span[1]")).getText();
		if(transmittalNo.equals(web_trans_no)){
			System.out.println(web_trans_no+" is CORRECT");
		}else{
			System.out.println(web_trans_no+" is INCORRECT");
		}
	}
	//VERIFY IF TRANSMITTAL DATE IS EQUALS TO TRANSMITTAL DATE OF ADMIN APP
	public void verify_transmittal_date(WebDriver driver, String option, String date){
		String currentDate="";
		String td = driver.findElement(By.xpath("//div[@id='mainContent']/div[7]/div/div/span[2]")).getText();
		if(option.equals("current")){
			currentDate = atl.date();
		}else{
			currentDate = date;
		}
		String convertedDate = convert_date(currentDate);
		if(td.equals(convertedDate)){
			System.out.println("Transmission Date is CORRECT");
		}else{
			System.out.println(td+" is not equals to "+convertedDate+"(TRANSMITTAL DATE)");
		}
	}
	public String convert_date(String date){
		String[] month = {
				"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
		};
		String[] dissectDate = date.split("/");
		String new_month="";
		int int_month = Integer.parseInt(dissectDate[0]);
		switch(int_month){
		case 1: new_month = month[int_month];
				break;
		case 2: new_month = month[int_month];
				break;
		case 3: new_month = month[int_month];
				break;
		case 4: new_month = month[int_month];;
				break;
		case 5: new_month = month[int_month];;
				break;
		case 6: new_month = month[int_month];;
				break;
		case 7: new_month = month[int_month];;
				break;
		case 8: new_month = month[int_month];;
				break;
		case 9: new_month = month[int_month];;
				break;
		case 10: new_month = month[int_month];;
				break;
		case 11: new_month = month[int_month];;
				break;
		case 12: new_month = month[int_month];;
				break;
		}
		String final_date = new_month+" "+dissectDate[1]+", "+dissectDate[2];
		return final_date;
	}
	//VERIFY IF AVAILMENT DATE IS EQUALS TO AVAILMENT OF ADMIN APP
	public void verify_availment_date(WebDriver driver, String date){
		String ad = driver.findElement(By.xpath("//div[@id='mainContent']/div[7]/div/div/span[3]")).getText();
		String convertedDate = convert_date(date);
		if(ad.equals(convertedDate)){
			System.out.println("Availment Date is CORRECT");
		}else{
			System.out.println(ad+" is not equals to "+convertedDate +"(AVAILMENT DATE)");
		}
	}
	//VERIFY IF TRANSMITTAL AMOUNT IS EQUALS TO TRANSMITTAL AMOUNT OF ADMIN APP
	public void verify_transmittal_amount(WebDriver driver, String amount){
		String new_amount = driver.findElement(By.xpath("//div[@id='mainContent']/div[7]/div/div/span[4]")).getText();
		new_amount = new_amount.replaceAll(",", "");
		if(new_amount.equals(amount)){
			System.out.println("Transmittal Amount is CORRECT");
		}else{
			System.out.println(new_amount+" is not equals to "+amount);
		}
	}
	//CLICK BACK BUTTON
	public void click_back_button(WebDriver driver){
		driver.findElement(By.xpath("//button[contains(.,'Back')]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	//CLICK PREVIEW BUTTON
	public void click_preview_transmittal_memo_button(WebDriver driver, boolean loa){
		driver.findElement(By.xpath("//button[contains(.,'Preview')]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		if(loa){
			driver.findElement(By.xpath("//button[@id='yesBtnDialog']")).click();
		}else{
			driver.findElement(By.xpath("//button[@id='noBtnDialog']")).click();
		}
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public String set_dropdown(String option){
		
		option = option.toLowerCase().toString();
		if(option.contains("soa")){
			option = "SOA Number";
		}
		else if(option.contains("ci")){
			option = "Charge Invoice";
		}
		else if(option.contains("pin")){
			option = "PIN";
		}
		else if(option.contains("visitno")){
			option = "Visit Number";
		}
		else if(option.contains("lname")){
			option = "Last Name";
		}
		return option;
	}
	public void search_it_on_transmittal(WebDriver driver, String option, String data) throws InterruptedException{
		Select options = new Select(driver.findElement(By.xpath("//select[@id='param']")));
		option = set_dropdown(option);
		options.selectByVisibleText(option);
		driver.findElement(By.xpath("//input[@id='paramValue']")).sendKeys(data);
		driver.findElement(By.xpath("//div[@id='searchDiv']/span/button[1]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		Thread.sleep(5000);
		String color = "";
		if(option.contains("CI")||option.contains("ci")||option.contains("Charge Invoice")){
			color = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr[1]/td[1]")).getAttribute("style");
		}else{
			color = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr[1]/td[1]")).getAttribute("style");
		}
		System.out.println(color);
		boolean newColor = dissect_attribute_style(color);
		if(newColor){
			System.out.println(option +" is highlighted. CORRECT!");
		}else{ System.out.println(option +" is not highlighted. INCORRECT!");}
		driver.findElement(By.xpath("//div[@id='searchDiv']/span/button[2]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public boolean dissect_attribute_style(String style){
		if(
				style.contains("background-color: yellow")
			||  style.contains("#FF0")
			||  style.contains("rgb(255, 255, 0)")
		  ){
			return true;
		}else{
			return false;
		}
	}
	public void get_data_for_search_on_transmittal(WebDriver driver, String option){
		String data="";
		System.out.println("Getting data of first row on INPATIENT ONLY. Except for CI.");
                int intoption = 0;
		if(option.equals("SOA")){
//			option = "SOA Number";
                        intoption = 1;
		}
		else if(option.equals("CI")){
//			option = "Charge Invoice";
                        intoption = 2;
		}
		else if(option.equals("PIN")){
//			option = "PIN";
                        intoption = 3;
		}
		else if(option.equals("VISITNO")){
//			option = "Visit Number";
                        intoption = 4;
		}
		else if(option.equals("LNAME")){
//			option = "Last Name";
                        intoption = 5;
		}
		switch(intoption){
			case 1: data = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr[1]/td[4]")).getText();
				     break;
			case 2: data = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr[1]/td[3]")).getText();
				     System.out.println("CI: "+data);
				     break;
			case 3: data = "1406065361";
                                     System.out.println("PIN is hardcoded.");
				     break;
			case 4: data =  driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr[1]/td[1]")).getText();
				     break;
			case 5: data = "COCOLIFE";
			             System.out.println("LastName is hardcoded.");
				      break;
		}
		try {
			search_it_on_transmittal(driver, option, data);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// THIS PORTION COMPARES DATA OF TRANSMITTAL FROM ADMINAPP TO WEBAPP
	public void start_comparison_of_transmittals(WebDriver driver, String[] inVisitNo, String[] outVisitNo){
		
		int a = inVisitNo.length +1;
		for(int y=1; y<a; y++){
			String[] inpatient_details = get_table_details_inpatient_hospital(driver, y);
			if(Arrays.asList(inVisitNo).contains(inpatient_details[0])){
				System.out.println(inpatient_details[0] + " : Match Found on array of visit number");
			}else{
				System.out.println(inpatient_details[0] + " : Match Not Found on array of visit number");
			}
		}
		
		int b = outVisitNo.length +1;
		for(int y=1; y<b; y++){
			String[] outpatient_details = get_table_details_outpatient_hospital(driver, y);
			if(Arrays.asList(outVisitNo).contains(outpatient_details[0])){
				System.out.println(outpatient_details[0] + " : Match Found on array of visit number");
			}else{
				System.out.println(outpatient_details[0] + " : Match Not Found on array of visit number");
			}
		}
	}
	public String[] get_table_details_inpatient_hospital(WebDriver driver, int x){
		
		String vn = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[1]")).getText();
		String ad = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[2]")).getText();
		String dd = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[3]")).getText();
		String soa = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[4]")).getText();
		String pn = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[5]")).getText();
		String ln = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[6]")).getText();
		String hb = driver.findElement(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr["+x+"]/td[7]")).getText();

		String tableText[] = { vn, ad, dd, soa, pn, ln, hb };
		return tableText;
	}
	public String[] get_table_details_outpatient_hospital(WebDriver driver, int x){
		
		String vn = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[1]")).getText();
		String ad = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[2]")).getText();
		String soa = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[3]")).getText();
		String pn = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[4]")).getText();
		String ln = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[5]")).getText();
		String hb = driver.findElement(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr["+x+"]/td[6]")).getText();

		String tableText[] = { vn, ad, soa, pn, ln, hb };
		return tableText;
	}
	public String[] get_table_details_inpatient_pf(WebDriver driver, int x){
		
		String vn = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[1]")).getText();
		String ad = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[2]")).getText();
		String dd = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[3]")).getText();
		String soa = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[4]")).getText();
		String dn = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[5]")).getText();
		String pn = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[6]")).getText();
		String pfa = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr["+x+"]/td[7]")).getText();

		String tableText[] = { vn, ad, dd, soa, dn, pn, pfa };
		return tableText;
	}
	public String[] get_table_details_outpatient_pf(WebDriver driver, int x){
		
		String vn = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[1]")).getText();
		String ad = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[2]")).getText();
		String soa = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[3]")).getText();
		String dn = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[4]")).getText();
		String pn = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[5]")).getText();
		String pfa = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr["+x+"]/td[6]")).getText();

		String tableText[] = { vn, ad, soa, dn, pn, pfa };
		
		return tableText;
		
	}
	public void start_comparison_of_transmittals_amount(
			WebDriver driver, 
			Double inpatient_hb, 
			Double outpatient_hb, 
			Double inpatient_pf, 
			Double outpatient_pf){
		
		double final_amount = 0;
		
		//GET INPATIENT COUNT
		List<WebElement> inVisitNum = driver.findElements(By.xpath("//div[@id='collapseOne']/div/table/tbody/tr"));
		int sizeIn = inVisitNum.size()+1;
		
		//LOOP FOR INPATIENT HOSPITAL BILL
		for(int y=1; y<sizeIn; y++){
			String[] inpatient_details = get_table_details_inpatient_hospital(driver, y);
			System.out.println(inpatient_details[6]);
			String myString = inpatient_details[6].replaceAll(",", "");
			double amount = Double.parseDouble(myString);
			final_amount = final_amount + amount;
		}
		Double inpatient_amount = final_amount;
		
		if(Math.abs(inpatient_hb-inpatient_amount) <= 0.000001){
			System.out.println("CORRECT INPATIENT HB. " +inpatient_hb+ " is equals to "+ inpatient_amount);
		}else{
			System.out.println("INCORRECT INPATIENT HB. " +inpatient_hb+ " is not equals to "+ inpatient_amount);
		}
				
		//GET OUTPATIENT COUNT
		List<WebElement> outVisitNum = driver.findElements(By.xpath("//div[@id='collapseTwo']/div/table/tbody/tr"));
		int sizeOut = outVisitNum.size()+1;
		
		//LOOP FOR OUTPATIENT HOSPITAL BILL
		final_amount = 0;
		for(int y=1; y<sizeOut; y++){
			String[] outpatient_details = get_table_details_outpatient_hospital(driver, y);
			System.out.println(outpatient_details[5]);
			double amount = Double.parseDouble((outpatient_details[5]).replaceAll(",", ""));
			final_amount = final_amount + amount;
		}
		Double outpatient_amount = final_amount;
		
		if(Math.abs(outpatient_hb-outpatient_amount) <= 0.000001){
			System.out.println("CORRECT OUTPATIENT HB. " +outpatient_hb+ " is equals to "+ outpatient_amount);
		}else{
			System.out.println("INCORRECT OUTPATIENT HB. " +outpatient_hb+ " is not equals to "+ outpatient_amount);
		}
		
		//GO TO PF TAB
		driver.findElement(By.xpath("//ul[@id='myTab']/li[2]/a")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
		//GET INPATIENT PF COUNT with VALIDATION IF NULL
		List<WebElement> inPf = driver.findElements(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr"));
		int sizeInPf = inPf.size();
		if(sizeInPf==1){
			String text = driver.findElement(By.xpath("//div[@id='collapseThree']/div/table/tbody/tr[1]/td[1]")).getText();
			if(text.contains("Nothing")){
				sizeInPf=0;
			}else{
				sizeInPf=sizeInPf+1;
			}
		}else{
			sizeInPf=sizeInPf+1;
		}
		
		//LOOP FOR INPATIENT PF
		final_amount = 0;
		for(int y=1; y<sizeInPf; y++){
			String[] inpatient_pf_details = get_table_details_inpatient_pf(driver, y);
			System.out.println(inpatient_pf_details[6]);
			String myString = inpatient_pf_details[6].replaceAll(",", "");
			double amount = Double.parseDouble(myString);
			final_amount = final_amount + amount;
		}
		Double new_inpatient_pf = final_amount;
		if(Math.abs(inpatient_pf-new_inpatient_pf) <= 0.000001){
			System.out.println("CORRECT INPATIENT PF. " +inpatient_pf+ " is equals to "+ new_inpatient_pf);
		}else{
			System.out.println("INCORRECT INPATIENT PF. " +inpatient_pf+ " is not equals to "+ new_inpatient_pf);
		}

		//GET OUTPATIENT PF COUNT with VALIDATION IF NULL
		List<WebElement> outPf = driver.findElements(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr"));
		int sizeOutPf = outPf.size();
		if(sizeOutPf==1){
			String text = driver.findElement(By.xpath("//div[@id='collapseFour']/div/table/tbody/tr[1]/td[1]")).getText();
			if(text.contains("Nothing")){
				sizeOutPf=0;
			}else{
				sizeOutPf=sizeOutPf+1;
			}
		}else{
			sizeOutPf=sizeOutPf+1;
		}
		
		//LOOP FOR OUTPATIENT PF
		final_amount = 0;
		for(int y=1; y<sizeOutPf; y++){
			String[] inpatient_pf_details = get_table_details_outpatient_pf(driver, y);
			System.out.println(inpatient_pf_details[5]);
			String myString = inpatient_pf_details[5].replaceAll(",", "");
			double amount = Double.parseDouble(myString);
			final_amount = final_amount + amount;
		}
		Double new_outpatient_pf = final_amount;
		if(Math.abs(outpatient_pf-new_outpatient_pf) <= 0.000001){
			System.out.println("CORRECT OUTPATIENT PF. " +outpatient_pf+ " is equals to "+ new_outpatient_pf);
		}else{
			System.out.println("INCORRECT OUTPATIENT PF. " +outpatient_pf+ " is not equals to "+ new_outpatient_pf);
		}
		
		//GO TO HB TAB
		driver.findElement(By.xpath("//ul[@id='myTab']/li[1]/a")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// THIS PORTION IS ABOUT TABLES IN TRANSMITTAL BEFORE CLICKING VIEW
	public void compare_data_to_search_output_via_table(
			WebDriver driver, 
			String transmittalNo, 
			String availDate, 
			String transmitDate,
			String amount)
	{
		String[] setIt = { transmitDate, transmittalNo, availDate, amount, "Final"};
		String getTransmitDate = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[1]")).getText();
		String getTransmitNo = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[2]")).getText();
		String getAvailDate = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[3]")).getText();
		String getAmount = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[4]")).getText();
		getAmount = getAmount.replaceAll(",", "");
		String getStatus = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[5]")).getText();
		
		String[] getIt = {getTransmitDate, getTransmitNo, getAvailDate, getAmount, getStatus};
		
		for(int x=0;x<setIt.length;x++){
			if(setIt[x].equals(getIt[x])){
				System.out.println(setIt[x]+" is equals to "+getIt[x]+" CORRECT");				
			}else{
				System.out.println(setIt[x]+" is not equals to "+getIt[x]+" INCORRECT");
			}
		}
	}
	public void view_transmittal_after_search(WebDriver driver){
		driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[6]/span/button")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// THIS PORTION IS ABOUT SEARCH TRANSMITTAL ON WEBAPP
	public void manual_date_picker_webapp(WebDriver driver, String date, String option){
		
		//Set manual date
		String new_loa_date[] = date.split("/"); 			
		int intDay= Integer.parseInt(new_loa_date[1]);
		String array_month[] = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
		
		if(option.equals("start")){
			driver.findElement(By.xpath("//input[@id='datepickerStart']")).click();
		}else{
			driver.findElement(By.xpath("//input[@id='datepickerEnd']")).click();
		}
				
		Select calendarMonth = new Select(driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/div/div/select[1]")));
		int month = Integer.parseInt(new_loa_date[0]);
		calendarMonth.selectByVisibleText(array_month[month]);
    	String stringDays = Integer.toString(intDay);
    	if(intDay>=1 && intDay<=6){
 		    try{
 		    	driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/table/tbody/tr[1]/td/a[.='"+stringDays+"']")).click();
 		    }catch(Exception e){
 		    	driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/table/tbody/tr[2]/td/a[.='"+stringDays+"']")).click();
 		    }
    	}else if(intDay>=26 && intDay<=31){
 		    try{
 		    	driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/table/tbody/tr[5]/td/a[.='"+stringDays+"']")).click();
 		    }catch(Exception e){
 		    	driver.findElement(By.xpath("//div[@id='ui-datepicker-div']/table/tbody/tr[6]/td/a[.='"+stringDays+"']")).click();
 		    }
    	}else{
    		driver.findElement(By.xpath("//a[contains(.,'"+stringDays+"')]")).click();
    	}
    	driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		
	}
	public void clear_search_transmittal(WebDriver driver){
		driver.findElement(By.xpath("//button[contains(.,'Clear')]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public void search_it_transmittal(WebDriver driver){
		driver.findElement(By.xpath("//button[contains(.,'Search')]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public void input_transmittal_number(WebDriver driver, String transmittalNo ){
		driver.findElement(By.xpath("//input[@id='transmittalField']")).sendKeys(transmittalNo);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public void select_location_of_transmittal(WebDriver driver, String loc){
		Select calendarMonth = new Select(driver.findElement(By.xpath("//select[@id='selLocation']")));
		String new_loc="";
		if(loc.equals("QC")){
			new_loc = "LOC001";
		}else{
			new_loc = "LOC002";
		}
		//calendarMonth.selectByVisibleText(new_loc);
		calendarMonth.selectByValue(new_loc);
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
	public void new_transmittal_counter(WebDriver driver){
		String counter = driver.findElement(By.xpath("//span[@id='newTrans']")).getText();
		if(counter.equals("1")){
			System.out.println(counter+" Transmittal has been added. CORRECT");
		}else{
			System.out.println(counter+" Transmittal. INCORRECT. Please make sure no new transmittal before running script. This should always be equals to 1.");
		}
	}
	public void new_text_beside_transmittal(WebDriver driver){
		String text = driver.findElement(By.xpath("//div[@id='displayTable']/div/table/tbody/tr/td[6]/span/span")).getText();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		if(text.equals("NEW")){
			System.out.println(text+ " is beside transmittal. CORRECT");
		}else{
			System.out.println(text+ " is beside transmittal. INCORRECT");
		}
	}
	
	////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// THIS PORTION IS ABOUT MISCELLANEOUS FUNCTIONS ON WEBAPP
	public void verify_search_results(WebDriver driver){
		List<WebElement> rows = driver.findElements(By.xpath("//table[@id='data']/tbody/tr"));
		int size = rows.size();
		
		try{
			String text = driver.findElement(By.xpath("//table[@id='data']/tbody/tr/td")).getText();
			if(text.equals("Nothing found to display.")){
				System.out.println("0 matches found in Transmittal");
			}else{
				System.out.println(size +" matches found in search in Transmittal");
			}
		}catch(Exception e){
			System.out.println("0 matches found in Transmittal");
		}
	}
	public void goto_transmittal_tab(WebDriver driver){
		
		driver.findElement(By.xpath("//div[@id='mainContent']/div[4]/nav/ul/li[3]")).click();
		driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
	}
}
